<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取元素</title>
</head>
<body>

    <div id="box">
        <p>这是段落</p>
        <p>这是段落</p>
        <p>这是段落</p>
        <p>这是段落</p>
    </div>
    <div id="box2">
        <h4 class="a">这是标题标签</h4>
        <h4 class="a">这是标题标签</h4>
        <p class="a">这是段落</p>
        <span class="a">这是span</span>
    </div>

    <script type="text/javascript">
        /**
         1，通过id获取页面id为box的div
         2，获取id为box下面的段落元素
         3.获取id为box2下面的所有类名为a的元素
         */
        var box1 = document.getElementById("box");
        // console.log(box1);

        var p1 = box1.getElementsByTagName("p");
        // console.log(p1);

        var box2 = document.getElementById("box2");
        var a = box2.getElementsByClassName("a");
        console.log(a);

    </script>

</body>
</html>